﻿using System.Collections.Generic;
using System.Web.Mvc;
using FluentValidation;
using FluentValidation.Attributes;
using Nop.Services.Localization;
using Nop.Web.Framework;
using Nop.Web.Framework.Localization;
using Nop.Web.Framework.Mvc;
using System.ComponentModel.DataAnnotations;
using Nop.Web.Models.Catalog;
using Nop.Web.Framework.Validators;

namespace Nop.Plugin.Widgets.Carousel.Models
{
    [Validator(typeof(CarouselValidator))]
    public partial class CarouselModel : BaseNopEntityModel
    {
        public CarouselModel()
        {
            AvailableCarouselEntities = new List<CarouselEntityModel>();
            //Products = new IEnumerable<ProductOverviewModel>();
        }

        [NopResourceDisplayName("Plugins.Widgets.Carousel.Fields.Name")]
        public string Name { get; set; }

        [NopResourceDisplayName("Plugins.Widgets.Carousel.Fields.WidgetZone")]
        public string WidgetZone { get; set; }

        [NopResourceDisplayName("Plugins.Widgets.Carousel.Fields.Published")]
        public bool Published { get; set; }

        [NopResourceDisplayName("Plugins.Widgets.Carousel.Fields.DisplayOrder")]
        public int DisplayOrder { get; set; }

        public IList<CarouselEntityModel> AvailableCarouselEntities { get; set; }
        public IEnumerable<ProductOverviewModel> Products { get; set; }
        
        //properties
        [NopResourceDisplayName("Plugins.Widgets.Carousel.Fields.isHiddenNav")]
        public bool isHiddenNav { get; set; }

        [NopResourceDisplayName("Plugins.Widgets.Carousel.Fields.NumberOfItems")]
        public int NumberOfItems { get; set; }

        [NopResourceDisplayName("Plugins.Widgets.Carousel.Fields.ItemMinWidth")]
        public int ItemMinWidth { get; set; }

        [NopResourceDisplayName("Plugins.Widgets.Carousel.Fields.ItemMargin")]
        public int ItemMargin { get; set; }

        [NopResourceDisplayName("Plugins.Widgets.Carousel.Fields.IsAutoRotate")]
        public bool IsAutoRotate { get; set; }

        [NopResourceDisplayName("Plugins.Widgets.Carousel.Fields.AutoRotate")]
        public int AutoRotate { get; set; }

        [NopResourceDisplayName("Plugins.Widgets.Carousel.Fields.CustomProductBox")]
        public bool CustomProductBox { get; set; }
        
    }


    public class CarouselValidator : BaseNopValidator<CarouselModel>
    {
        public CarouselValidator(ILocalizationService localizationService)
        {
            RuleFor(x => x.Name).NotNull().WithMessage(localizationService.GetResource("Plugins.Widgets.Carousel.Fields.Name.Required"));
        }
    }
}